package com.med.meddataintegrator.common.basic.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    private  Integer code;
    private String msg;
    private Object data;

    public JsonResult(StatusCode statusCode) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
    }
    public JsonResult(StatusCode statusCode, Object data) {
        this.code = statusCode.getCode();
        this.msg = statusCode.getMsg();
        this.data = data;
    }
    public JsonResult(String msg) {
        this.msg = msg;
    }
    public static JsonResult ok(Object data) {
        return new JsonResult(StatusCode.OPERATION_SUCCESS, data);
    }
    public static JsonResult ok() {
        return ok(null);
    }
    public static JsonResult fail(StatusCode statusCode) {
        return new JsonResult(statusCode);
    }
    public static JsonResult fail(String msg) {
        return new JsonResult(msg);
    }

}
